package net.togogo.egouweb1238.core.service.product.impl;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.togogo.egouweb1238.common.utils.PageController;
import net.togogo.egouweb1238.core.dao.product.BrandDao;
import net.togogo.egouweb1238.core.domain.product.Brand;
import net.togogo.egouweb1238.core.query.product.BrandQuery;
import net.togogo.egouweb1238.core.service.product.IBrandService;


/**
 * 品牌管理实现
 * @author stone
 *
 */
@Service(value="brandService")
@Transactional
public class BrandServiceImpl implements IBrandService{
	
	@Resource
	private BrandDao brandDao;

	@Override
	public void addBrand(Brand brand) {
		brandDao.addBrand(brand);
	}

	@Override
	public void deleteBrandById(Integer id) {
		brandDao.deleteBrandById(id);
		
	}

	@Override
	public void deleteBrandByIds(Integer[] ids) {
		brandDao.deleteBrandByIds(ids);
		
	}

	@Override
	public void updateBrand(Brand brand) {
		brandDao.updateBrand(brand);
		
	}

	@Override
	public Brand getBrandById(Integer id) {
		return brandDao.getBrandById(id);
	}

	/**
	 * 参数：
	 * pc：分页对象
	 * brand：查询条件
	 */
	@Override
	public List<Brand> getBrandsWithPage(PageController pc,Brand brand) {
		HashMap map = new HashMap();
		map.put("isDisplay", brand.getIsDisplay());
		map.put("name", brand.getName());
		map.put("pageStartRow", pc.getPageStartRow());
		map.put("pageSize", pc.getPageSize());
		List<Brand> brands = brandDao.getBrandsWithPage(map);
		
		return brands;
	}

	@Override
	public int getBrandCount(Brand brand) {
		return brandDao.getBrandCount(brand);
	}

	@Override
	public List<Brand> getBrandList(BrandQuery brandQuery) {
		return brandDao.getBrandList(brandQuery);
	}

}
